package lab22;

//import java.util.ArrayList;
//import java.util.Collections;
//import java.awt.RenderingHints.Key;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
//import java.util.HashSet;
//import java.util.Iterator;
import java.util.Map;
//import java.util.Set;
//import java.util.TreeSet;

public class ShipComparator implements Comparator<Ship> {

	@Override
	public int compare(Ship ship1, Ship ship2) {
		return ship1.getShipName().compareTo(ship2.getShipName());
	}

	public static void main(String[] args) {
////		ShipComparator comparator = new ShipComparator();
////		ArrayList<Ship> list = new ArrayList<Ship>();
		Ship sh = new Ship(48, 7, 8, "Titanic", "Gosho");
		Ship sh1 = new Ship(250, 236, 4, "Mayflower", "Murphy");
		Ship sh2 = new Ship(42, 9, 7, "Spam", "Pesho");
//		
//		Set<Ship> set = new HashSet<Ship>();
//		set.add(sh);
//		set.add(sh1);
//		set.add(sh2);
//		
//		for (Iterator<Ship> it = set.iterator(); it.hasNext(); ) {
//			System.out.println(it.next());
//		}
//		
////		System.out.println(set.first() + " " + set.last());
		
		Map<String, Ship> map = new HashMap<String, Ship>();
		map.put("Titanic", sh);
		map.put("Mayflower", sh1);
		map.put("Spam", sh2);
		
		for (Iterator<String> it = map.keySet().iterator(); it.hasNext(); ) {
			String key = it.next();
			System.out.println(key + ": " + map.get(key));
		}
	}

}
